﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using AdAggregator.Monitoring;

namespace ClothingAggregator.Models.Monitoring
{
    public class MyMonitoringResult
    {
        public virtual MyAdvertisement Advertisement { get; set; }
        
        [Key]
        [ForeignKey("Advertisement")]
        public int Id { get; set; }

        public DateTime LastUpdate { get; set; }
        
        [InverseProperty("History")]
        public virtual MyMonitoringTask MonitoringTask { get; set; }

        [ForeignKey("MonitoringTask")]
        public string MonitoringTaskId { get; set; }

        public MyMonitoringResult(){}
        public MyMonitoringResult(IMonitoringResult<MyAdvertisement> other)
        {
            LastUpdate = other.LastUpdate;
            MonitoringTaskId = other.MonitoringTaskId;
            if (other.PricedAdvertisement != null)
            {
                Id = other.PricedAdvertisement.Id;
            }
        }
    }
}